package com.czxy.servlet;

import cn.itcast.servlet.BaseServlet;
import com.alibaba.fastjson.JSON;
import com.czxy.domain.Product;
import com.czxy.service.ProductService;

import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.util.List;

@WebServlet("/productServlet")
public class ProductServlet extends BaseServlet {

    //最新商品
    public  void  findNewProducts() throws IOException {

        ProductService service = new ProductService();

        List<Product> newProducts = service.findNewProducts();

        String s = JSON.toJSONString(newProducts);

        getResponse().getWriter().write(s);

    }



    //热门商品
    public  void  findHotProducts() throws IOException {

        ProductService service = new ProductService();

        List<Product> hotProducts = service.findHotProducts();

        String s = JSON.toJSONString(hotProducts);

        getResponse().getWriter().write(s);

    }
}